package com.learn.strategy.impl;

import com.learn.strategy.FormSubmitHandler;
import com.learn.strategy.dto.CommonPairResponse;
import com.learn.strategy.dto.FormSubmitRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author tuzhijin
 * @version Id: FormModelSubmitHandler.java, v 0.1 2021/3/21 下午1:58 tuzhijin Exp $$
 */
@Component
@Slf4j
public class FormModelSubmitHandler implements FormSubmitHandler {

    @Override
    public String getSubmitType() { return "model"; }

    @Override
    public CommonPairResponse handleSubmit(FormSubmitRequest request) {
        log.info("模型提交：userId={}, formInput={}", request.getUserId(), request.getFormInput());

        // 模型创建成功后获得模型的 id
        Long modelId = createModel(request);

        return CommonPairResponse.success("模型提交成功！", modelId);
    }

    private Long createModel(FormSubmitRequest request) {
        // 创建模型的逻辑
        return 123L;
    }
}

